WKSPCDIR=$(HOME)/workspace
MAINDIR=$(WKSPCDIR)/pargoOPENMP
SRCDIR=${MAINDIR}/src
LIBDIR=${MAINDIR}/lib
BINDIR=${MAINDIR}/bin

COMB=Comb
BKTRK=BackTrack
MCR=MCR
MCS=MCS
STABSOLV=StabSolver
STAB=Stab
FRAC=Frac
REPLAG=RepLag

# ---------------------------------------------------------------------
# Compiler options 
# ---------------------------------------------------------------------

CCOMPILER= g++ -D__cplusplus
COPT= -m32 -O3
#CCFLAGS = -I. -I$(GRAPHDIR) -I$(IPDIR)

# ---------------------------------------------------------------------
# Entries
# ---------------------------------------------------------------------

HEAP=heap
REPO=repository
GRAPH=Graph
GRAPHS=Graphs
WGRAPHS=WGraphs
DSTDIR=datastrct
GRAPHDIR=graph
COMBDIR=combsolvers
STABDIR=stab
IPDIR=ipsolvers
LAGDIR=lagsolvers

INCDIRS=$(wildcard $(SRCDIR)/*)
DIRS=$(SRCDIR)/$(DSTDIR) $(SRCDIR)/$(GRAPHDIR) ${SRCDIR}/$(COMBDIR) $(SRCDIR)/$(STABDIR) $(SRCDIR)/$(IPDIR) $(SRCDIR)/$(LAGDIR)

MAKEOPT=CCOMPILER="$(CCOMPILER)" COPT="$(COPT)" LIBDIR=$(LIBDIR) INCDIRS="$(INCDIRS)"

INCFLAGS=$(addprefix -I,$(INCDIRS))

-include ../main/CPLEXMAKE

deps:
	@$(foreach DIR,$(DIRS), make --directory=$(DIR) -s $(MAKEOPT);)
	
$(COMB): Main.cpp deps Makefile
	$(CCOMPILER) ${INCFLAGS} -D_COMBSOLV_ -fopenmp -g -o $(BINDIR)/$@ ${COPT} $(LIBDIR)/$(GRAPH).o $(LIBDIR)/$(GRAPHS).o  $(LIBDIR)/$(REPO).o $(LIBDIR)/$(BKTRK).o $(LIBDIR)/$(MCR).o $(LIBDIR)/$(MCS).o -lrt -pthread $<
	
$(STAB): Main.cpp deps Makefile
	$(CCOMPILER) ${INCFLAGS} -D_IPSOLV_ -fopenmp -g -o $(BINDIR)/$@ ${COPT} $(LIBDIR)/$(HEAP).o $(LIBDIR)/$(GRAPH).o $(LIBDIR)/$(GRAPHS).o $(LIBDIR)/$(WGRAPHS).o $(LIBDIR)/$(STABSOLV).o $(LIBDIR)/$(STAB).o $(LIBDIR)/$(FRAC).o $(LIBDIR)/$(REPLAG).o $(CPLEXFLAGS) -lrt -pthread -lgmp $<
	
# ------------------------------------------------------------

clean:
	/bin/rm -rf $(LIBDIR)/*.o

